1617B - GCD Problem - CodeForces Solution


brute force constructive algorithms math number theory *900

Please click on ads to support us..

Python Code:

for n in[*map(int,open(0))][1:]:print(m:=(2,n//4*2-1)[n%2],n-m-1,1)

C++ Code:

#include<bits/stdc++.h>
bool salom(long long x)
{
    for (int i = 2; i <= sqrt(x); i++)
    {
        if (x % i == 0)
        {
            return false;
        }
    }
        return true;
}
using namespace std;
void wrongontest2()
{
    int n,a;
    cin>>n;
    for (int i = 0; i < n; i++)
    {
        cin>>a;
        if (a % 2 == 0)
        {
            cout << 4 << " " << a - 5 << " " << 1 << endl;
        }
        else
        {
            if ((a/2) % 2 == 0)
            {
                cout << a / 2+1 << " " << a/2-1 << " " << 1 << endl;
            }
            else
            {
                cout << a / 2 + 2 << " " << a/ 2 - 2 << " " << 1 << endl;
            }
        }
    }
}
int main ()
{
    int t=1;
    //cin>>t;
    while(t--)
    {
      wrongontest2();
    }
}


Comments

Submit
0 Comments
More Questions

1088B - Ehab and subtraction
1270B - Interesting Subarray
478C - Table Decorations
1304C - Air Conditioner
1311C - Perform the Combo
1519C - Berland Regional
361A - Levko and Table
5E - Bindian Signalizing
687A - NP-Hard Problem
1542C - Strange Function
961E - Tufurama
129D - String
888A - Local Extrema
722B - Verse Pattern
278A - Circle Line
940A - Points on the line
1742C - Stripes
1742F - Smaller
1742B - Increasing
1742A - Sum
1742D - Coprime
390A - Inna and Alarm Clock
1398B - Substring Removal Game
1742G - Orray
416B - Art Union
962A - Equator
803B - Distances to Zero
291A - Spyke Talks
1742E - Scuza
1506D - Epic Transformation